package huoye.shops.huoye.operation.adapter;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.codeideology.android.widget.recycler.RecyclerViewAdapter;

import butterknife.BindView;
import huoye.shops.R;
import huoye.shops.huoye.operation.model.ManageEventData;
import huoye.shops.widget.RoundImageView;

import static huoye.shops.huoye.operation.fragment.ManageEventFragment.TYPE_MANAGE_EVENT_DNS;
import static huoye.shops.huoye.operation.fragment.ManageEventFragment.TYPE_MANAGE_EVENT_START;


/**
 * Created by uesr on 2018/8/10.
 */

public class MineSetEventAdapter extends RecyclerViewAdapter<MineSetEventAdapter.ViewHolder,ManageEventData> {





    public MineSetEventAdapter(Context context) {
        super(context, R.layout.item_mine_set_event);
    }

    @Override
    protected ViewHolder initViewHolder(View view, int i) {

        return new ViewHolder(view);
    }

    @Override
    protected void bindView(ViewHolder holder, final ManageEventData manageEventData, int i) {

        holder.tvEventName.setText("我创建的活动");
        if( manageEventData.getiState() == TYPE_MANAGE_EVENT_DNS ){
            holder.tvEventStare.setSelected(false);
            holder.tvEventStare.setText("活动未开始");
        }else if(manageEventData.getiState() == TYPE_MANAGE_EVENT_START ){
            holder.tvEventStare.setSelected(false);
            holder.tvEventStare.setText("活动进行中");
        }else  {
            holder.tvEventStare.setSelected(true);
            holder.tvEventStare.setText("已结束");
        }
        holder.tvEventTime.setText("活动期限"+manageEventData.getEndTime());
        holder.tvEventExplain.setText(manageEventData.getRemarks());

        holder.btnDetails.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onDetailsClick(manageEventData);
            }
        });

    }


    public class ViewHolder extends RecyclerViewAdapter.ViewHolder {


        @BindView(R.id.item_mine_set_event_tv_event_name)
        TextView tvEventName;

        @BindView(R.id.item_mine_set_event_tv_event_state)
        TextView tvEventStare;

        @BindView(R.id.item_mine_set_event_tv_event_explain)
        TextView tvEventExplain;

        @BindView(R.id.item_mine_set_event_tv_event_time)
        TextView tvEventTime;



        @BindView(R.id.item_mine_set_event_btn_details)
        Button btnDetails ;


        public ViewHolder(View itemView) {
            super(itemView);
        }
    }



    public void setOnMineSetEventListener(OnMineSetEventListener onMineSetEventListener) {
        this.listener = onMineSetEventListener;
    }

    private OnMineSetEventListener listener;

    public interface OnMineSetEventListener {

        void onDetailsClick(ManageEventData ManageEventData);



    }

}
